import {AfterViewInit, Component, Input, OnInit, TemplateRef, ViewChild} from '@angular/core';

import {Hero} from '../hero';
import {HeroService} from '../services/hero.service';
import {HerosComponent} from 'src/app/heros/heros.component';
import {AdItem} from '../ad-banner/job-ad/ad-item';
import {AdService} from '../services/ad.service';


@Component({
  selector: 'app-dashboard',
  templateUrl: './dashboard.component.html',
  // template: '<h2>hello world</h2>',
  styleUrls: ['./dashboard.component.css'],
  // providers: []
})
export class DashboardComponent implements OnInit, AfterViewInit {

  heros: Hero[] = [];
  ads: AdItem[];
  test = 'hello child';
  filed1 = 'filed1';

  color: string;
  constructor(private heroService: HeroService, private adService: AdService) {
  }

  ngOnInit() {
    JSON.stringify('');
    this.ads = this.adService.getAds();
    this.getHeros();
  }

  getHeros(): void {
    this.heroService.getHeros().subscribe(val => this.heros = val);
  }

  vt(agree) {
    if (agree) {
      console.log(agree);
    } else {
      console.log(`agree: ${agree}`);
    }
  }

  ngAfterViewInit(): void {

  }

}
